package com.om.base;

import java.sql.Connection;

import javax.servlet.http.HttpServletRequest;

public abstract class BaseConnectionManage {
	public static String Server = "";
	public static String UserName = "";
	public static String Password = "";
	public static String DataBase = "";

	public static Class ConnectionManageClass = null;

	public static Connection getAvailableConnection() {
		Connection con = null;

		BaseConnectionManage cManage = null;
		try {
			cManage = (BaseConnectionManage) Class.forName(
					ConnectionManageClass.getName()).newInstance();
			con = cManage.getConnection();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return con;
	}

	public static Connection getAvailableConnection(String poolName) {
		Connection con = null;

		BaseConnectionManage cManage = null;
		try {
			cManage = (BaseConnectionManage) Class.forName(
					ConnectionManageClass.getName()).newInstance();
			con = cManage.getConnection(poolName);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return con;
	}
	
	public static Connection getAvailableConnection(String poolName,HttpServletRequest req) {
		Connection con = null;

		BaseConnectionManage cManage = null;
		try {
			cManage = (BaseConnectionManage) Class.forName(
					ConnectionManageClass.getName()).newInstance();
			con = cManage.getConnection(poolName);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return con;
	}
	

	public static Connection getAvailableWriteConnection() {
		Connection con = null;

		BaseConnectionManage cManage = null;
		try {
			cManage = (BaseConnectionManage) Class.forName(
					ConnectionManageClass.getName()).newInstance();
			con = cManage.getWriteConnection();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return con;
	}

	public static Connection FreeConnection(Connection con) {

		BaseConnectionManage cManage = null;
		try {
			cManage = (BaseConnectionManage) Class.forName(
					ConnectionManageClass.getName()).newInstance();
			cManage.freeConnection(con);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return con;
	}

	protected abstract Connection getConnection();

	protected abstract Connection getWriteConnection();

	protected abstract Connection getConnection(String poolName);

	protected abstract void freeConnection(Connection con);
}

/*
 * Location: D:\temp\omtask\WEB-INF\classes\ Qualified Name:
 * com.om.Abstract.BaseConnectionManage JD-Core Version: 0.5.3
 */